package com.ryan.mdp.advice.service;

public class MetricsKey {
    // 服务标示
    private String server;
    // 服务Ip
    private String serverIp;
    // 来源标示
    private String source;
    // 来源Ip
    private String sourceIp;
    // 服务接口
    private String interfaze;
    // 服务方法
    private String method;

    public MetricsKey() {
    }

    public MetricsKey(String server, String serverIp, String source, String sourceIp, String interfaze, String method) {
        this.server = server;
        this.serverIp = serverIp;
        this.source = source;
        this.sourceIp = sourceIp;
        this.interfaze = interfaze;
        this.method = method;
    }

    public String toString() {
        return "MetricsKey [server=" + server + ", serverIp=" + serverIp + ", source=" + source + ", sourceIp="
                + sourceIp + ", interfaze=" + interfaze + ", method=" + method + "]";
    }

    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((interfaze == null) ? 0 : interfaze.hashCode());
        result = prime * result + ((method == null) ? 0 : method.hashCode());
        result = prime * result + ((server == null) ? 0 : server.hashCode());
        result = prime * result + ((serverIp == null) ? 0 : serverIp.hashCode());
        result = prime * result + ((source == null) ? 0 : source.hashCode());
        result = prime * result + ((sourceIp == null) ? 0 : sourceIp.hashCode());
        return result;
    }

    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        MetricsKey other = (MetricsKey) obj;
        if (interfaze == null) {
            if (other.interfaze != null)
                return false;
        } else if (!interfaze.equals(other.interfaze))
            return false;
        if (method == null) {
            if (other.method != null)
                return false;
        } else if (!method.equals(other.method))
            return false;
        if (server == null) {
            if (other.server != null)
                return false;
        } else if (!server.equals(other.server))
            return false;
        if (serverIp == null) {
            if (other.serverIp != null)
                return false;
        } else if (!serverIp.equals(other.serverIp))
            return false;
        if (source == null) {
            if (other.source != null)
                return false;
        } else if (!source.equals(other.source))
            return false;
        if (sourceIp == null) {
            if (other.sourceIp != null)
                return false;
        } else if (!sourceIp.equals(other.sourceIp))
            return false;
        return true;
    }
}
